# encoding: utf-8
'''
Created: 2014-04-25 14:07

@author: VAN
'''
import time
import urllib2

from BeautifulSoup import BeautifulSoup


def deco():
    from t import decorator
    decorator.objfunc()
    decorator.objfunc1(1, 2)
    
# deco();


def top():
    urlf = 'http://y.qq.com/y/static/toplist/json/top/{topIndex}/1.js?loginUin=0&hostUin=0&format=jsonp&inCharset=GB2312&outCharset=utf-8&notice=0&platform=yqq&jsonpCallback=MusicJsonCallback&needNewCode=0'
    for index in [1, 2, 6, 7, 10, 11, 12]:
        url = urlf.format(topIndex=index)
        req = urllib2.Request(url=url)
        rsp = urllib2.urlopen(req).read()
        
        print rsp;
    
def http():
    url = 'http://y.qq.com/y/static/toplist/index/global_12.html?pgv_ref=qqmusic.y.toplist.global_12';
    req = urllib2.Request(url);
    rsp = urllib2.urlopen(req).read()
#     print rsp
    
    soup = BeautifulSoup(rsp)
    data = soup.findAll('a', attrs={'class':'data'});
    for item in data:
        print item.text
    
http()

print '+++++++++++handle+++++++++++'
    
